#include <Length.h>
#include <iostream>
#include <sstream>

#define COEFFICIENTPERMILE 5280
#define COEFFICIENTPERYARD 3
#define COEFFICIENTPERFEET 1

LengthUnit::LengthUnit(const int coeffientOfBaseUnit): Unit(coeffientOfBaseUnit,TYPE_LENGTH)
{   
}

const LengthUnit& LengthUnit::Mile()
{
  static LengthUnit unit(COEFFICIENTPERMILE);
  return unit;
}

const LengthUnit& LengthUnit::Yard()
{
  static LengthUnit unit(COEFFICIENTPERYARD);
  return unit;
}

const LengthUnit& LengthUnit::Feet()
{
  static LengthUnit unit(COEFFICIENTPERFEET);
  return unit;
} 
const std::string LengthUnit::showUnitStepString(int amount)
{
    ostringstream os;
    int baseUnitValue = this->getBaseVlaue(amount);
    int mileValue = 0;
    int yardValue = 0;

    if(baseUnitValue)
    {
       if(mileValue = baseUnitValue / COEFFICIENTPERMILE) 
       {
          baseUnitValue = baseUnitValue % COEFFICIENTPERMILE;
          if(baseUnitValue)
            os << mileValue << " Mile ";
          else
            os << mileValue << " Mile";
       }
       if(yardValue = baseUnitValue / COEFFICIENTPERYARD) 
       {
          baseUnitValue = baseUnitValue % COEFFICIENTPERYARD;
          if(baseUnitValue)
            os << yardValue << " Yard ";
          else
            os << yardValue << " Yard";
       }
       if(baseUnitValue) 
       {
          os << amountInMile << " Feet";
       }
    }
    else
    {
        os << baseUnitValue << " Feet";
    }  
   
   cout<< os.str() << "!" <<endl;
   return os.str();
}
const std::string LengthUnit::showBaseUnitString(int amount)
{
    ostringstream os;
    int baseUnitValue = this->getBaseVlaue(amount);
    os << baseUnitValue << " Feet";
    cout<< os.str() << "!" <<endl;
    return os.str();
}



